package com.iecampus.view;

import com.iecampus.moldel.PublishedItem;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.ListView;

public class MListView extends ListView {
	private int mLastx;

	public MListView(Context context) {
		super(context);
	}

	public MListView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	private SlideView mFocusedItemView;

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		int x = (int) event.getX();
		int y = (int) event.getY();
		int scrollX = 0;
		switch (event.getAction()) {
		case MotionEvent.ACTION_MOVE:
			scrollX = Math.abs(x-mLastx);
			int position = pointToPosition(x, y);
			if (position != INVALID_POSITION ) {
				PublishedItem data = (PublishedItem) getItemAtPosition(position);
				mFocusedItemView = data.slideView;
			}
			break;

		default:
			break;
		}
		mLastx = x;
		if (mFocusedItemView != null ) {
			mFocusedItemView.onTouchEvent(event);
		}
		return super.onTouchEvent(event);
	}
}
